<template>
  <div>
      <router-link :to="{name:'good_post'}">添加</router-link>
      <router-link :to="{name:'good_search'}">搜索</router-link>
      <table>
          <tr v-for="data in datas">
              <td>{{data.id}}</td>
              <td>{{data.name}}</td>
              <td>{{data.sale}}</td>
              <td>{{data.price}}</td>
              <td>{{data.cate_id}}</td>
              <td>
                  <router-link :to="{name:'good_detial',query:{'id':data.id}}">详情</router-link>
              </td>
          </tr>
      </table>
      <el-pagination
      :total="total"
      :current-page.sync="page"
      :page-size="2"
      @current-change='getdata'
      ></el-pagination>
  </div>
</template>

<script>
export default {
    name:'good_get',
    data(){
        return{
            cate_id:this.$route.query.cate_id,
            page:1,
            datas:[],
            total:0
        }
    },
    methods:{
        getdata(){
            this.axios.get('yt6/',{
                params:{
                    page:this.page,
                    cate_id:this.cate_id
                    }
                })
                    .then(res=>{
                        console.log(res.data)
                        this.datas=res.data.goods
                        this.total=res.data.total
            })
        },
        
    },
    mounted(){
        this.getdata()
    }

}
</script>

<style>

</style>